0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 316 ms)
↳10 BOUNDS(1, n^2)
f(true, x, y) → f(gt(x, y), s(x), s(s(y)))
gt(0, v) → false
gt(s(u), 0) → true
gt(s(u), s(v)) → gt(u, v)
f(true, x, y) → f(gt(x, y), s(x), s(s(y))) [1]
gt(0, v) → false [1]
gt(s(u), 0) → true [1]
gt(s(u), s(v)) → gt(u, v) [1]
f(true, x, y) → f(gt(x, y), s(x), s(s(y))) [1]
gt(0, v) → false [1]
gt(s(u), 0) → true [1]
gt(s(u), s(v)) → gt(u, v) [1]
f :: true:false → s:0 → s:0 → f true :: true:false gt :: s:0 → s:0 → true:false s :: s:0 → s:0 0 :: s:0 false :: true:false |
f(v0, v1, v2) → null_f [0]
null_f
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 1
0 => 0
false => 0
null_f => 0
f(z, z', z'') -{ 1 }→ f(gt(x, y), 1 + x, 1 + (1 + y)) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
f(z, z', z'') -{ 0 }→ 0 :|: v0 >= 0, z'' = v2, v1 >= 0, z = v0, z' = v1, v2 >= 0
gt(z, z') -{ 1 }→ gt(u, v) :|: v >= 0, z' = 1 + v, z = 1 + u, u >= 0
gt(z, z') -{ 1 }→ 1 :|: z = 1 + u, z' = 0, u >= 0
gt(z, z') -{ 1 }→ 0 :|: v >= 0, z' = v, z = 0
eq(start(V, V1, V2),0,[f(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]). eq(start(V, V1, V2),0,[gt(V, V1, Out)],[V >= 0,V1 >= 0]). eq(f(V, V1, V2, Out),1,[gt(V3, V4, Ret0),f(Ret0, 1 + V3, 1 + (1 + V4), Ret)],[Out = Ret,V1 = V3,V2 = V4,V = 1,V3 >= 0,V4 >= 0]). eq(gt(V, V1, Out),1,[],[Out = 0,V5 >= 0,V1 = V5,V = 0]). eq(gt(V, V1, Out),1,[],[Out = 1,V = 1 + V6,V1 = 0,V6 >= 0]). eq(gt(V, V1, Out),1,[gt(V7, V8, Ret1)],[Out = Ret1,V8 >= 0,V1 = 1 + V8,V = 1 + V7,V7 >= 0]). eq(f(V, V1, V2, Out),0,[],[Out = 0,V9 >= 0,V2 = V10,V11 >= 0,V = V9,V1 = V11,V10 >= 0]). input_output_vars(f(V,V1,V2,Out),[V,V1,V2],[Out]). input_output_vars(gt(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [gt/3]
1. recursive : [f/4]
2. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into gt/3
1. SCC is partially evaluated into f/4
2. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations gt/3
* CE 8 is refined into CE [9]
* CE 7 is refined into CE [10]
* CE 6 is refined into CE [11]
### Cost equations --> "Loop" of gt/3
* CEs [10] --> Loop 7
* CEs [11] --> Loop 8
* CEs [9] --> Loop 9
### Ranking functions of CR gt(V,V1,Out)
* RF of phase [9]: [V,V1]
#### Partial ranking functions of CR gt(V,V1,Out)
* Partial RF of phase [9]:
- RF of loop [9:1]:
V
V1
### Specialization of cost equations f/4
* CE 5 is refined into CE [12]
* CE 4 is refined into CE [13,14,15,16]
### Cost equations --> "Loop" of f/4
* CEs [16] --> Loop 10
* CEs [15] --> Loop 11
* CEs [14] --> Loop 12
* CEs [13] --> Loop 13
* CEs [12] --> Loop 14
### Ranking functions of CR f(V,V1,V2,Out)
* RF of phase [10]: [V1-V2]
#### Partial ranking functions of CR f(V,V1,V2,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V1-V2
### Specialization of cost equations start/3
* CE 2 is refined into CE [17,18,19,20]
* CE 3 is refined into CE [21,22,23,24]
### Cost equations --> "Loop" of start/3
* CEs [24] --> Loop 15
* CEs [22] --> Loop 16
* CEs [20] --> Loop 17
* CEs [19,23] --> Loop 18
* CEs [17,18] --> Loop 19
* CEs [21] --> Loop 20
### Ranking functions of CR start(V,V1,V2)
#### Partial ranking functions of CR start(V,V1,V2)
Computing Bounds
=====================================
#### Cost of chains of gt(V,V1,Out):
* Chain [[9],8]: 1*it(9)+1
Such that:it(9) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[9],7]: 1*it(9)+1
Such that:it(9) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [8]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [7]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of f(V,V1,V2,Out):
* Chain [[10],14]: 2*it(10)+1*s(3)+0
Such that:it(10) =< V1-V2
aux(1) =< 2*V1-V2
s(3) =< it(10)*aux(1)
with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]
* Chain [[10],11,14]: 2*it(10)+1*s(3)+1*s(4)+2
Such that:it(10) =< V1-V2
aux(1) =< 2*V1-V2
s(4) =< 2*V1-V2+1
s(3) =< it(10)*aux(1)
with precondition: [V=1,Out=0,V2>=1,V1>=V2+1]
* Chain [14]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0]
* Chain [13,14]: 2
with precondition: [V=1,V1=0,Out=0,V2>=0]
* Chain [12,[10],14]: 2*it(10)+1*s(3)+2
Such that:it(10) =< V1
aux(1) =< 2*V1
s(3) =< it(10)*aux(1)
with precondition: [V=1,V2=0,Out=0,V1>=2]
* Chain [12,[10],11,14]: 2*it(10)+1*s(3)+1*s(4)+4
Such that:it(10) =< V1
aux(1) =< 2*V1
s(4) =< 2*V1+1
s(3) =< it(10)*aux(1)
with precondition: [V=1,V2=0,Out=0,V1>=2]
* Chain [12,14]: 2
with precondition: [V=1,V2=0,Out=0,V1>=1]
* Chain [12,11,14]: 1*s(4)+4
Such that:s(4) =< 3
with precondition: [V=1,V1=1,V2=0,Out=0]
* Chain [11,14]: 1*s(4)+2
Such that:s(4) =< V1+1
with precondition: [V=1,Out=0,V1>=1,V2>=V1]
#### Cost of chains of start(V,V1,V2):
* Chain [20]: 1
with precondition: [V=0,V1>=0]
* Chain [19]: 1*s(20)+1*s(21)+4*s(24)+2*s(25)+4
Such that:s(20) =< 3
s(22) =< V1
s(23) =< 2*V1
s(21) =< 2*V1+1
s(24) =< s(22)
s(25) =< s(24)*s(23)
with precondition: [V>=0,V1>=0,V2>=0]
* Chain [18]: 1*s(26)+1*s(27)+2
Such that:s(27) =< V
s(26) =< V1+1
with precondition: [V>=1,V1>=V]
* Chain [17]: 1*s(28)+4*s(31)+2*s(32)+2
Such that:s(29) =< V1-V2
s(30) =< 2*V1-V2
s(28) =< 2*V1-V2+1
s(31) =< s(29)
s(32) =< s(31)*s(30)
with precondition: [V=1,V2>=1,V1>=V2+1]
* Chain [16]: 1
with precondition: [V1=0,V>=1]
* Chain [15]: 1*s(33)+1
Such that:s(33) =< V1
with precondition: [V1>=1,V>=V1+1]
Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [20] with precondition: [V=0,V1>=0]
- Upper bound: 1
- Complexity: constant
* Chain [19] with precondition: [V>=0,V1>=0,V2>=0]
- Upper bound: 4*V1+7+4*V1*V1+ (2*V1+1)
- Complexity: n^2
* Chain [18] with precondition: [V>=1,V1>=V]
- Upper bound: V+V1+3
- Complexity: n
* Chain [17] with precondition: [V=1,V2>=1,V1>=V2+1]
- Upper bound: 6*V1-5*V2+3+ (4*V1-2*V2)* (V1-V2)
- Complexity: n^2
* Chain [16] with precondition: [V1=0,V>=1]
- Upper bound: 1
- Complexity: constant
* Chain [15] with precondition: [V1>=1,V>=V1+1]
- Upper bound: V1+1
- Complexity: n
### Maximum cost of start(V,V1,V2): max([max([V+V1+2,nat(2*V1-V2+1)+1+nat(V1-V2)*4+nat(2*V1-V2)*2*nat(V1-V2)]),3*V1+6+4*V1*V1+ (2*V1+1)+V1])+1
Asymptotic class: n^2
* Total analysis performed in 235 ms.